package com.baichang.taoshunda.service.impl;

import com.baichang.framework.excelption.ServiceException;
import com.baichang.framework.utils.LogUtils;
import com.baichang.taoshunda.job.AddCompanyMoneyJob;
import com.baichang.taoshunda.service.InitProjectsService;
import com.baichang.taoshunda.service.TwoSchedulerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by yuliang on 2016/9/7.
 */
@Service
public class InitProjectsServiceImpl implements InitProjectsService {

    @Autowired
    private TwoSchedulerService schedulerService;

    @Override
    public void start() {
        LogUtils.getInstance().info("start:+++++++++++++++++++++++++++++++++++>");
        schedulerService.start();
        try {
            schedulerService.deleteAllJob();
            schedulerService.addSchedulerByCron("0 0 0/1 * * ? ", AddCompanyMoneyJob.class, "123456");
        } catch (ServiceException e) {
            e.printStackTrace();
        }
        LogUtils.getInstance().info("start------------------------------------->");
    }

    @Override
    public void close() {
        LogUtils.getInstance().info("end+++++++++++++++++++++++++++++++++++>");
        schedulerService.close();
        LogUtils.getInstance().info("end------------------------------------->");
    }
}
